﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Sector7.Medical.EntityType;
using Sector7.Medical.Utility;

namespace Sector7.Medical.Controls
{
    /// <summary>
    /// OutpatientCard.xaml 的交互逻辑
    /// </summary>
    public partial class PatientCard : UserControl
    {
        #region ======================= Main Functions =======================

        /// <summary>
        /// 加载病人信息
        /// </summary>
        /// <param name="patient"></param>
        public void LoadPatient(M7_Patient patient)
        {
            if (patient != null)
            {
                txbPatientId.Text = patient.PatientId.ToString();
                txbFullName.Text = patient.FullName;
                txbGender.Text = patient.Gender.GenderName;
                txbAge.Text = CitizenUtil.CalculateAge(patient.Birthday);
                txbBirthday.Text = patient.Birthday.ToShortDateString();
                imgAvatar.Source = InterfaceUtil.GetAvatar(patient.CitizenId);
            }
            else
            {
                ResetPatientCard();
            }
        }

        /// <summary>
        /// 重置病人信息控件
        /// </summary>
        public void ResetPatientCard()
        {
            txbPatientId.Text = string.Empty;
            txbFullName.Text = string.Empty;
            txbGender.Text = string.Empty;
            txbAge.Text = string.Empty;
            txbBirthday.Text = string.Empty;
            imgAvatar.Source = InterfaceUtil.GetDefaultAvatar();
        }

        /// <summary>
        /// 加载控件事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            ResetPatientCard();
        }

        #endregion

        #region ======================= Accessor =======================

        #endregion

        #region ======================= Private functions =======================

        #endregion

        #region ======================= Structure =======================

        /// <summary>
        /// 构造方法
        /// </summary>
        public PatientCard()
        {
            InitializeComponent();
        }

        #endregion

        #region ======================= Inner members =======================
        
        #endregion
    }
}
